unit uDemo;

interface

function RandomWideString: WideString;
function RandomAnsiString: AnsiString;
function RandomString: string;

implementation

const
  BASE64_ALPHABETS: array [0..64] of AnsiChar =
  ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
   'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
   'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
   'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
   'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
   'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
   'w', 'x', 'y', 'z', '0', '1', '2', '3',
   '4', '5', '6', '7', '8', '9', '+', '/', '=');

function RandomAnsiString: AnsiString;
var
  i: Integer;
begin
  SetLength(Result, Random(10) + 20);
  for i := 1 to Length(Result) do
    Result[i] := BASE64_ALPHABETS[Random(Length(BASE64_ALPHABETS)) +
      Low(BASE64_ALPHABETS)];
end;

function RandomWideString: WideString;
var
  i: Integer;
begin
  SetLength(Result, Random(10) + 20);
  for i := 1 to Length(Result) do
    Result[i] := WideChar(BASE64_ALPHABETS[Random(Length(BASE64_ALPHABETS)) +
      Low(BASE64_ALPHABETS)]);
end;

function RandomString: string;
var
  i: Integer;
begin
  SetLength(Result, Random(10) + 20);
  for i := 1 to Length(Result) do
    Result[i] := Char(BASE64_ALPHABETS[Random(Length(BASE64_ALPHABETS)) +
      Low(BASE64_ALPHABETS)]);
end;

end.
